from selenium import webdriver
from selenium.webdriver.chrome.webdriver import WebDriver


class BasePage:
    _base_url = ""
    def __init__(self,base_driver = None):
        if base_driver is None:
            chrome_org = webdriver.ChromeOptions()
            chrome_org.debugger_address = "127.0.0.1:9222"
            self.driver = webdriver.Chrome(options=chrome_org)
            # self.driver.get("https://work.weixin.qq.com/wework_admin/frame#index")
            self.driver.get(self._base_url)
            self.driver.implicitly_wait(5)

        else:
            self.driver:WebDriver = base_driver

    def find(self,by,locator = None):
        if locator == None:
            return self.driver.find_element(*by)
        else:
            return self.driver.find_element(by=by,value=locator)